package test;
import java.io.*;
import java.util.Set;
import javax.servlet.*;
import javax.servlet.http.*;
public class Checkout extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		HttpSession session=request.getSession();
		ShoppingCart sc=(ShoppingCart)session.getAttribute("ShoppingCart");
		if(sc==null) {
			sc=new ShoppingCart();
		}
		Set<Goods> set=sc.keySet();
		int cnt;
		response.setHeader("Cache-Control", "no-cache");
		response.setContentType("text/html;charset=gbk");
		PrintWriter out=response.getWriter();
		for(Goods goods:set) {
			cnt=sc.get(goods);
			out.print("<p>");
			out.print(goods.getName());
			out.print("<br/>");
			out.print("单价");
			out.print(goods.getPrice());
			out.print("&nbsp;&nbsp;&nbsp;&nbsp;");
			out.print("数量");
			out.print(cnt);
			out.print("</p>");
		}
		out.print("<p>订单总额");
		out.print(sc.check());
		out.print("元</p>");
	}
}
